package com.ruoyi.web.controller.process;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.WorkMoveplate;
import com.ruoyi.process.service.IWorkMoveplateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 移盘管理Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/process/moveplate")
public class WorkMoveplateController extends BaseController
{
    @Autowired
    private IWorkMoveplateService workMoveplateService;

    /**
     * 查询移盘管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:moveplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkMoveplate workMoveplate)
    {
        startPage();
        List<WorkMoveplate> list = workMoveplateService.selectWorkMoveplateList(workMoveplate);
        return getDataTable(list);
    }

    /**
     * 导出移盘管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:moveplate:export')")
    @Log(title = "移盘管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkMoveplate workMoveplate)
    {
        List<WorkMoveplate> list = workMoveplateService.selectWorkMoveplateList(workMoveplate);
        ExcelUtil<WorkMoveplate> util = new ExcelUtil<WorkMoveplate>(WorkMoveplate.class);
        return util.exportExcel(list, "移盘管理数据");
    }

    /**
     * 获取移盘管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:moveplate:query')")
    @GetMapping(value = "/{workMoveplateId}")
    public AjaxResult getInfo(@PathVariable("workMoveplateId") Long workMoveplateId)
    {
        return AjaxResult.success(workMoveplateService.selectWorkMoveplateById(workMoveplateId));
    }

    /**
     * 新增移盘管理
     */
    @PreAuthorize("@ss.hasPermi('process:moveplate:add')")
    @Log(title = "移盘管理", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type= InjectType.Insert)
    public AjaxResult add(@RequestBody WorkMoveplate workMoveplate)
    {
        return toAjax(workMoveplateService.insertWorkMoveplate(workMoveplate));
    }

    /**
     * 修改移盘管理
     */
    @PreAuthorize("@ss.hasPermi('process:moveplate:edit')")
    @Log(title = "移盘管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type= InjectType.Update)
    public AjaxResult edit(@RequestBody WorkMoveplate workMoveplate)
    {
        return toAjax(workMoveplateService.updateWorkMoveplate(workMoveplate));
    }

    /**
     * 删除移盘管理
     */
    @PreAuthorize("@ss.hasPermi('process:moveplate:remove')")
    @Log(title = "移盘管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workMoveplateIds}")
    public AjaxResult remove(@PathVariable Long[] workMoveplateIds)
    {
        return toAjax(workMoveplateService.deleteWorkMoveplateByIds(workMoveplateIds));
    }
}
